home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue25 / compress / COMPRESS.ZIP / DOINSTAL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-07-09  |  1.4 KB  |  45 lines

  1. unit DoInstal;
  2.  
  3. { TCompress 3.0 routine to install a self-extracting archive from a
  4.   compressed resource -- no change from V2.5
  5.  See SELFEXTF.PAS or SELFXSML.DPR for detailed information on this file }
  6.  
  7. interface
  8.  
  9. procedure DoInstall(TargetDir, ExeFilename, ReadmeFilename: string);
  10.  
  11. implementation
  12. uses WinTypes, WinProcs, Classes, SysUtils  ,Compress;
  13.  
  14. const  RESOURCE_NAME = 'MyArchiv';
  15.  
  16. procedure DoInstall(TargetDir, ExeFilename, ReadmeFilename: string);
  17. var TempStream: TStream;
  18.     NameBuff: Array[0..255] of char;
  19.     Compress: TCompress;
  20. begin
  21.  Compress := TCompress.Create(nil);
  22.  with Compress do
  23.  begin
  24.    TempStream := LoadCompressedResource(RESOURCE_NAME,'');
  25.    { Right -- at this point TempStream has our compressed file in
  26.      a stream we can usefully access. Start at the beginning! }
  27.    try
  28.       RegNumber := 0; { your TCompress registration ID }
  29.       RegName := 'Your name';
  30.       MakeDirectories := True;
  31.       Targetpath := TargetDir;
  32.       if TempStream<>nil then
  33.         ExpandFilesFromStream(TempStream,nil); { get the lot }
  34.    finally
  35.       TempStream.free;
  36.    end;
  37.  end;
  38.  if ReadMeFileName<>'' then { if we get here, we should have expanded ok }
  39.     WinExec(strPCopy(NameBuff,'NOTEPAD '+TargetDir+ReadMeFileName),sw_Show);
  40.  if EXEFileName<>'' then { if we get here, we should have expanded ok }
  41.     WinExec(strPCopy(NameBuff,TargetDir+EXEFileName),sw_Show);
  42. end;
  43.  
  44. end.
  45.